package com.restkeeper.dubbo;


import com.restkeeper.tenant.TenantContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @ClassName: DubboConsumerContextFilter
 * @description: TODO
 * @author: 有罗敷的马同学
 * @datetime: 2023Year-05Month-17Day-9:35
 * @Version: 1.0
 */
@Activate
@Slf4j
public class DubboConsumerContextFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        RpcContext.getContext().setAttachment("shopId", TenantContext.getShopId());
        RpcContext.getContext().setAttachment("loginUserId", TenantContext.getShopId());
        RpcContext.getContext().setAttachment("loginUserName", TenantContext.getLoginUserName());
        RpcContext.getContext().setAttachment("storeId", TenantContext.getStoreId());
        return invoker.invoke(invocation);
    }
}
